export const setCookie =(name:string,value:string,expire:number)=>{

  let cookie = name + "=" + encodeURIComponent(value);
    if (typeof expire === "number") {
        cookie += "; max-age=" + (expire*24*60*60); // max-age单位是秒
    }
    document.cookie = cookie;

}

export const  getCookie= (name:string) =>{
  const cookies = document.cookie.split("; ");
  for (let i = 0; i < cookies.length; i++) {
      const [cookieName, cookieValue] = cookies[i].split("=");
      if (name === cookieName) {
          return decodeURIComponent(cookieValue);
      }
  }
  return "";
}